<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>注册</title>
    <link rel="stylesheet" href="./css/regst.css">
</head>
<body>
    <div class="head">
        <div class="head1">
            <div class="imgbox">
                <img src="./img/log1.png" alt="">
            </div>
            <a href="./index.html" target="_blank"><div class="sy">首页</div></a>
            <div class="lx">
                热线 : 400-9993-513
            </div>
        </div>
    </div>

    <div class="life">
        <div class="life1">
            <div class="imgbos">
                <img src="./img/log2.jpg" alt="">
            </div>



            <div class="logon1">
                <div class="on">
                    <div class="on1">
                        注册
                    </div>
                    <div class="on2">
                        已有账户？&nbsp;
                        <a href="./logon.html"><span>点击登录</span></a>
                    </div>
                </div>

                <div class="phone">
                    <span>
                        <input type="text" value="手机" class="phonein">
                    </span>
                </div>
                <div class="pass">
                    <span>
                        <input type="text" value="密码" class="passin">
                    </span>
                </div>

                <div class="record">
                    同意协议并注册
                </div>
                
                <span class="msg"></span>
            </div>


        </div>
    </div>

    <div class="foot">
        <div class="foot1">
            <ul class="foot_wk">
                <li>关于我们 <span> / </span> &nbsp;</li>
                <li> 配送政策 <span> / </span> &nbsp;</li>
                <li> 招才纳贤 <span> / </span> &nbsp;</li>
                <li> 帮助中心 <span> / </span> &nbsp;</li>
                <li> 联系我们 <span> / </span> &nbsp;</li>
                <li> 招商加盟 <span> / </span> &nbsp;</li>
                <li> 网站地图 <span> / </span> &nbsp;</li>
                <li> 词条部落</li>
            </ul><br>
            <p>Copyright 2016, 茶七网 TEA7.COM</p>
            <p>增值电信业务经营许可证 : B1.B2-20160011 &nbsp;&nbsp;&nbsp; 闽CP备14011677号-2</p>
            <p>服务时间 : 08:30-21:00 &nbsp;客服热线:400-9993-513（温馨提示 : 请您核对无误后拨出，谢谢！）</p>
            <span><img src="https://rr.knet.cn/static/images/logo/cnnic.png" alt=""></span>
            <span><img src="./img/cert.png" alt=""></span>
        </div>
        <div class="foot2">
            <div class="bos2">
                <img src="./img/guanzhu_weixin_90.jpg" class="imgbos2">
                <p><img src="./img/weixin.png" class="imgbos1"></p>
                <p class="imgbos3">扫描关注微信公众号</p>
            </div>
            <div class="bos2">
                <img src="./img/erweima.jpg" class="imgbos2">
                <p class="imgbos4">APP</p>
                <p class="imgbos3">扫描关注微信公众号</p>
            </div>
        </div>
    </div>
</body>
</html>
<script src="ajax-promise.js"></script>
<script>
    class regst{
        constructor(){
            this.tel = document.querySelector(".phonein");
            this.pass = document.querySelector(".passin");
            this.record = document.querySelector(".record");
            this.msg = document.querySelector(".msg");

            this.url = "http://api.icodeilife.cn:81/user";

            this.addevent();
        }

        addevent(){
            var that = this;
            this.record.onclick = function(){
                that.t = that.tel.value;
                that.p = that.pass.value;

                that.load();
            }
        }

        load(){
            ajax({
                url:this.url,
                data:{
                    type:"register",
                    user:this.t,
                    pass:this.p,
                    tel:"",
                    email:""
                }
            }).then((res)=>{
                this.res = JSON.parse(res);

                this.display();
            })
        }

        display(){
            if(this.res.code == 1){
                this.msg.innerHTML = this.res.msg + ",2秒后到登录页面";
                setTimeout(() => {
                    location.href = "logon.html";
                }, 2000);
            }else{
                this.msg.innerHTML = this.res.msg;
            }
        }
    } 

    new regst();
</script>